{template header}
<!--main-->
<style>
    .menu a{
        color:black;
        font-weight:normal;
        font-size:10px
    }
    .menu .active{
        font-weight:bold
    }


</style>
<div class="container">


    <div class="row top10">
        <dl>
            <dd>


           <h3 style="padding:10px;display: flex ">

               <div>
                   <select onChange="MM_jumpMenu('parent',this,0)" style="width: 60px;font-size:10px;font-weight: 300;height: 20px" >
                       <option value="{tsUrl('user','apply',array('status'=>$status,'page'=>$page))}">全体</option>
                       {loop $strGroup $key $item}
                       <option value="{tsUrl('user','apply',array('status'=>$status,'groupid'=>$item['groupid'],'page'=>$page))}" {if $groupid==$item['groupid']}selected{/if}>{$item['groupname']}</option>
                       {/loop}
                   </select>
               </div>

               <div class="menu" style="margin-left: 10px;line-height: 20px">
                <a {if $status==''}class="active"{/if} href="{SITE_URL}index.php?app=user&ac=apply&groupid={$groupid}">未办</a>  |
                <a {if $status==1}class="active"{/if} href="{SITE_URL}index.php?app=user&ac=apply&status=1&groupid={$groupid}">已办</a>  |
                   <small style="font-size: 10px">&nbsp;&nbsp;计数：{$ApplyNum}</small>
               </div>
               {if !isMobile()&& $GLOBALS['TS_USER']['isadmin']=='1' }
               <div style="position: absolute;right: 15px;top: 15px;"><a class="btn btn-default btn-sm" style="height:20px;padding-top: 2px" data-toggle="modal" data-target="#upload">导入</a></div>
               {/if}



    </h3>



    <ul>
        <li><a style="width:100%" class="btn btn-success" data-toggle="modal" data-target="#do_apply_form">{if $GLOBALS['TS_USER']['isrezheng']=='1'}申报{else}申请认证{/if}</a></li>
        <li>
        <span style="width: 15%">姓名</span><span style="width: 15%">类别</span><span style="width:18%">申报时间</span><span style="width:20%">所属团队</span>{if $GLOBALS['TS_USER']['isadmin']=='1'} <span style="width:18%">操作</span>{/if}
        </li>
    </ul>
         <ul>
        {loop $arrApply $key $item}
            <li>
           <span style="width: 15%;"><a href="{tsUrl('user','duty',array('id'=>$item[user][userid]))}" style='color:{if strtotime('-2 week') >$item[addtime] && $item[status]==0 }orange{else}{if $item[status]==2}red{else}#434343{/if}{/if};{if $item[status]==1 }text-decoration:line-through;{/if}'> {$item[user][username]}</a></span>
           <span style="width: 15%">{$item['typename']}</span>
           <span style="width: 18%">{php echo date('Y-m-d',$item['addtime'])}</span>

            <span style="width: 20%">{$item['user']['groupname']}</span>
                {if $GLOBALS['TS_USER']['isadmin']=='1'}
            <span style="width: 18%;line-height: 20px">

                {if $item['status']==0|| $item['status']==2}
                     <a  onclick="issue('{$item[applyid]}')">[颁发]</a>
                <!--
                {if $item['status']==0}
                     <a onclick="refuse('{$item[applyid]}')">[拒发]</a>
                {/if}-->
                {else}
                     <a  onclick="deissue('{$item[applyid]}')">[未发]</a>
                {/if}

            </span>
                {/if}
             </li>
        {/loop}
        </ul>
                </dd>
            </dl>
        <div class="page">{$pageUrl}</div>
    </div>

</div>



<div id="do_apply_form" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true" >
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h5 class="modal-title">选择种类</h5>
                <div><small>如果申请馆员资格证书，需要通过考试，我们会核对您的成绩；</small></div>
                <div><small>如果申请勋章，只能申请等于或小于当前等级的勋章。</small></div>
                <div><small>不符合申请条件的，将会被驳回。</small></div>
            </div>
            <div class="modal-body" >
                <form  id="apply" class="form-horizontal"  method="post" action="{SITE_URL}index.php?app=user&ac=do&ts=apply">
                    <input name="groupid" type="hidden" value="{$mygroupid}">
                    <div class="form-group">
                        <div class="col-sm-12">

                                {if !in_array(1,$myApplyType)}
                                <div><input name="type[]"  type="checkbox" value="1" onclick="showscorebox()"/>&nbsp;&nbsp;馆员资格证书</div>
                                {/if}

                                {if $arrUser['roleid']>1&&!in_array(2,$myApplyType)}
                                <div><input name="type[]"  type="checkbox" value="2" />&nbsp;&nbsp;志士勋章</div>
                                {/if}
                                {if $arrUser['roleid']>3&&!in_array(3,$myApplyType)}
                                <div><input name="type[]"  type="checkbox" value="3" />&nbsp;&nbsp;仁人勋章</div>
                                {/if}
                                {if $arrUser['roleid']>6&&!in_array(4,$myApplyType)}
                                <div><input name="type[]"  type="checkbox" value="4" />&nbsp;&nbsp;贤者勋章</div>
                                {/if}
                                {if $arrUser['roleid']>9&&!in_array(5,$myApplyType)}
                                    <div><input name="type[]"  type="checkbox" value="5" />&nbsp;&nbsp;元勋勋章</div>
                                {/if}

                        </div>


                    </div>
                    <div class="form-group" style="display:none" id="score-box">
                        <div class="col-sm-offset-0 col-sm-10">
                            <input type="text" id="score" name="score" value="" class="form-control" placeholder="请填写自测成绩">
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-offset-2 col-sm-10">
                            <button type="submit" class="btn btn-success">提交</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>


<div class="modal fade" id="upload" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <form class="form-horizontal ajaxForm2" id='formadd'  method="post" enctype="multipart/form-data" action="{SITE_URL}index.php?app=user&ac=do&ts=upload_excel">
        <div class="modal-dialog" >
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"
                            aria-hidden="true">×
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        导入Excel
                    </h4>
                </div>

                <div class="modal-body">
                    <div class="row">
                        <div class="col-xs-12">


                            <div class="form-group">

                                <div class="col-sm-9">
                                    <input type="file" name="excelData"  multiple="true" datatype="*4-50" />
                                    <span class="Validform_checktip"></span>

                                </div>
                            </div>


                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="submit" id='formbtn'  class="btn btn-primary">
                        提交保存
                    </button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </form>
</div><!-- /.modal -->


<div id="apply_finish" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true" >
    <div class="modal-dialog">
        <div class="modal-content">

            <div class="modal-body" >

                    <div class="form-group">
                        <p class="col-sm-12">

                                <p>
                                    <span>

                                        <i class="fa fa-check-circle"></i> 祝贺你，你已经获得系统认证，成为候任馆员。

                                    </span>
                                </p>

                                <p>
                                    <i class="fa fa-check-circle"></i> 你现在已经取得了进入分馆工作群和大本营的资格；<br/>向小新发送“{$groupname}馆员”，ta会邀请你加入分馆工作群和大本营。<small style="color: red">小贴士：近期小新因为频繁接待微澜伙伴，被微信系统认为行为可疑，你可能会收到风险提示，请忽略。另外小新发送的群邀请链接第一次点击可能显示“邀请过期”，请重新点击一次，就可能刷新了。</small>
                                </p>
                                <p><img src="http://park.sanzhi.org.cn/uploadfile/editor/0/1/1205.jpg" style="width: 100px;height:100px"></p>




                        </div>
                    </div>


            </div>
        </div>
    </div>
</div>

<script>
    function showscorebox(){

            $('#score-box').toggle();

    }

    function issue(applyid){

        if (confirm('已颁发相应证章吗？')) {
            $.ajax({
                type: "POST",
                url: siteUrl+"index.php?app=user&ac=do&ts=issue",
                data: "applyid="+applyid,
                beforeSend:function(){
                },
                success:function(result){
                    if(result == '1'){
                        window.location.reload();
                    }
                }
            });

        }
    }

    function deissue(applyid){

        if (confirm('相应证章还没发吗？')) {
            $.ajax({
                type: "POST",
                url: siteUrl+"index.php?app=user&ac=do&ts=deissue",
                data: "applyid="+applyid,
                beforeSend:function(){
                },
                success:function(result){
                    if(result == '1'){
                        window.location.reload();
                    }
                }
            });

        }
    }

    function refuse(applyid){

        if (confirm('拒绝这项申请吗？')) {
            $.ajax({
                type: "POST",
                url: siteUrl+"index.php?app=user&ac=do&ts=refuse",
                data: "applyid="+applyid,
                beforeSend:function(){
                },
                success:function(result){
                    if(result == '1'){
                        window.location.reload();
                    }
                }
            });

        }
    }

    $(function(){
        $('#apply').on('submit', function(e) {
            var type  = getCheckboxValue('type[]');

            if(type ==''){
                bootbox.alert('请选择证章的各类');
                return false;
            }
            if(in_array(1,type)){
                var score =  $('#score').val();
                if(score ==''){
                    bootbox.alert('请填写自测成绩');
                    return false;
                }else{
                    if(score < 80 ){
                        bootbox.alert('成绩低于80分，不能申请证书');
                        return false;
                    }
                }
            }

        });

    });


</script>

{if $apply==1}
<script>

    $('#do_apply_form').modal('show');

</script>

{/if}

{if $sort==1}
<script>

    $('#apply_finish').modal('show');

</script>

{/if}

{template footer}